package com.woniuxy.common.mapper;

import com.woniuxy.common.entity.MarketMessage;
import com.woniuxy.common.entity.MarketMessageExample;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

public interface MarketMessageMapper {
    long countByExample(MarketMessageExample example);

    int deleteByExample(MarketMessageExample example);

    int deleteByPrimaryKey(String id);

    int insert(MarketMessage record);

    int insertSelective(MarketMessage record);

    List<MarketMessage> selectByExample(MarketMessageExample example);

    MarketMessage selectByPrimaryKey(String id);

    int updateByExampleSelective(@Param("record") MarketMessage record, @Param("example") MarketMessageExample example);

    int updateByExample(@Param("record") MarketMessage record, @Param("example") MarketMessageExample example);

    int updateByPrimaryKeySelective(MarketMessage record);

    int updateByPrimaryKey(MarketMessage record);

    @Select("select * from market_message where senduser_id=#{sendUserId} order by date DESC")
    List<MarketMessage> selectAllMessagesBySendId(String sendUserId);

    @Select("select * from market_message where senduser_id=#{loginuserid} " +
            "and receiveuser_id=#{userid} and commodity_id=#{commodityid}")
    MarketMessage selectMessageByInfo(@Param("loginuserid") String loginuserid,
                                      @Param("commodityid") String commodityid,
                                      @Param("userid") String userid);

    @Update("update market_message set date=#{date} where id=#{id} ")
    int updateDate(@Param("id") String id,@Param("date") Date date);

}